<%--
<%@ page language="java" pageEncoding="utf-8"%>
<div class="searchBox">
	<img class="qidian" src="/images/qidian.png">
	<span id="info"></span>
	<img class="down" src="/images/down.png">
	<input class="search-input" type="text" id="tipinput" placeholder="你从哪上车">
	<span id="cancelBtn">取消</span>
</div>
<div id="container"></div> 
<div class="no-result text-center">
	<img src="/images/no.png">
	&lt;%&ndash;<p>暂无搜索结果，换个词试试吧</p>&ndash;%&gt;
</div>
<script type="text/javascript">
    var city = getLocalStorage('city', 'string');
    document.getElementById('info').innerHTML = '' + city;
    autoComplete();
</script>--%>

<%@ page language="java" pageEncoding="utf-8" %>
<%@include file="../common/base.jsp"%>
<div class="searchBox row">
	<div class="col-xs-5 showCityBox">
		<img class="qidian" src="${base}/images/zhongdian.png">
		<span id="city_info"></span>
		<img class="down" src="${base}/images/down.png">
	</div>
	<div class="col-xs-5 inputCityBox hide">
		<input type="text" class="search-city" placeholder="城市中文或拼音">
	</div>
	<div class="col-xs-7 inputAddressBox">
		<img id="input_delete" class="hide" src="${base}/images/input_delete.png" alt="">
		<input class="search-input" type="text" id="tipinput" placeholder="你从哪儿上车">
		<span id="cancelBtn">取消</span>
	</div>
</div>
<div id="container"></div>
<div class="searchResultList hide" style="margin-top: 50px;"></div>
<div class="no-result text-center hide">
	<img src="${base}/images/no.png">
	<p>暂无搜索结果，换个词试试吧</p>
</div>
<script type="text/javascript">

    (function ($) {
        var height = $(window).height();
        $('.kucity_body').css("height", height - 50)

        var city = getLocalStorage('city', 'string');
        document.getElementById('city_info').innerHTML = '' + city;

        // 触发城市搜索，显示输入框
        $(".showCityBox").on('touchend', function (event) {
            // 初始化城市搜索
            var $kucity = $('.search-city').kuCity({
                isLocalhost:true,
                isQuery:true,
			});
            var $this = $(this);
            $this.addClass('hide').next().removeClass('hide');
            $('#historyBox').addClass('hide');
            $('.searchResultList').addClass('hide');
            $('.search-city').val('');
            $kucity.init();
//            var hotCity = $kucity.hotCity['hot'];
            $kucity.container.find('.kucity_nav').hide();
            $kucity.container.find('.result').hide();
            $kucity.container.find('.active').show().siblings().hide();
            var activeContainer = $kucity.container.find('.active dd');
            activeContainer.html("");
            getLocalCity().then(function (data) {
                var d=data;
                var dt;
                for(var i =0;i< d.length;i++){
                    var di=d[i];
                    if(getLocalStorage('isTaxi')=='true' && di.type==1){
                        dt=di.resources;
                        break;
                    }else if( di.type==2){
                        dt=di.resources;
                        break;
                    }
                }
                var str = '<p class="kucity-current">当前城市：' + getLocalStorage('city', 'string') + '</p>';
                for (var j = 0, jLen = dt.length; j < jLen; j++) {
                    str += '<span>' + dt[j].name + '</span>';
                }
                str += '<p class="kucity-current text-center">其他城市陆续开通中...</p>';
                activeContainer.html(str);
                $kucity.container.show().offset({
                    'top': 50,
                    'left': 0
                });
                $kucity.triggleShow(true);
            });
//            var str = '<p class="kucity-current">当前城市：' + getLocalStorage('city', 'string') + '</p>';
//            for (var j = 0, jLen = hotCity.length; j < jLen; j++) {
//                str += '<span>' + hotCity[j] + '</span>'
//            }
//            activeContainer.html(str);

//            $kucity.container.find('.kucity_nav').show();
//            $kucity.container.find('.result').show();
//            $kucity.container.find('.kucity_item').show();

//            $kucity.container.show().offset({
//                'top': 50,
//                'left': 0
//            });
        });

        // 触发具体地点输入input
        $(".inputAddressBox").on('touchend', function (event) {

            $('.inputCityBox').addClass('hide');
            $('.showCityBox').removeClass('hide');
            $('#historyBox').removeClass('hide');
        });

        $('#input_delete').on('touchend', function (event) {

            $('#tipinput').val('');
        });
        function getLocalCity() {
            var promise = new Promise(function (resolve) {
                $.get('/api/v1/passenger/sysBusinessCity/list',{
                    appid:appid,
                    sign:'1',
                    noncestr:'1'
                }, function (res) {
                    if (res.success) {
                        resolve(res.data);
                    }
                });
            });
            return promise;
        }

    })(jQuery);

</script>
